//
//  UIButton+XMKit.h
//  XMKit
//
//  Created by chenming on 2018/6/24.
//  Copyright © 2018年 ChenXiaoMing. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, XMButtonEdgeInsetsStyle) {
    XMButtonEdgeInsetsStyleTop, // image在上，label在下
    XMButtonEdgeInsetsStyleLeft, // image在左，label在右
    XMButtonEdgeInsetsStyleBottom, // image在下，label在上
    XMButtonEdgeInsetsStyleRight // image在右，label在左
};

typedef void(^buttonHandler)(UIButton *btn);

@interface UIButton (XMKit)

/** 点击范围 */
@property(nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;

/** 按钮响应 */
@property (nonatomic, copy) buttonHandler eventHandler;


/**
 设置点击样式和范围
 
 @param style 图片位置
 @param space 偏移量
 */
- (void)layoutButtonWithEdgeInsetsStyle:(XMButtonEdgeInsetsStyle)style
                        imageTitleSpace:(CGFloat)space;

#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdeprecated-declarations"

/**
 block按钮响应事件
 
 @param block 按钮block
 @param controlEvents 响应controlEvents
 */
- (void)addEventHandler:(void(^)(UIButton * btn))block forControlEvents:(UIControlEvents)controlEvents;
#pragma clang diagnostic pop

@end
